package com.example.es;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @Author：wlz
 * @Package：com.example.es
 * @Project：redis
 * @name：ESTest_Index_Create
 * @Date：2023/4/15 22:18
 * @Filename：ESTest_Index_Create
 */
public class ESTest_Doc_Delete {
    public static void main(String[] args) throws IOException {
        //创建
        RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200)));
        //查询数据
        DeleteRequest request = new DeleteRequest();
        request.index("user1").id("1001");


        DeleteResponse index = client.delete(request, RequestOptions.DEFAULT);

        //响应状态
        System.out.println(index.getResult());

        //关闭
        client.close();
    }
}
